package lnp;

import static org.junit.Assert.assertEquals;
import lnp.test.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * Illustrates JUnit testing of Robocode robots.
 * This test simply verifies that FiringDock has 50% chance to beats the Walls.
 * 
 * @author Lyneth Peou
 *
 */
public class TestFiringDockVersusWalls extends RobotTestBed {

  /**
   * Specifies that Walls and FiringDock are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Walls,lnp.FiringDock";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * The actual test, which asserts that FiringDock has won Walls at least 5 rounds.
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of getRobotNames.
    BattleResults[] results = event.getIndexedResults();
    
    // Check to make sure FiringDock win 5 rounds.
    assertEquals("Check FiringDock winner", results[1].getFirsts(), (getNumRounds() / 2));
  }
}
